
package com.yunfei.api.product;

import com.yunfei.bo.product.ProductBeiAnBo;
import com.yunfei.bo.product.ProductPageBo;
import com.yunfei.bo.result.ResultModel;
import com.yunfei.enums.ResultStatus;
import com.yunfei.mapper.aiiidb.*;
import com.yunfei.service.ValidTokenService;
import com.yunfei.utils.string.StringUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @Description: 产品页面接口
 * @Author: zhengyunfei
 * @Date: 2018/6/15
 * @time:11:26
 */
@SuppressWarnings("ALL")
@Api(value = "首页产品信息",tags = "首页产品信息")
@RestController
@RequestMapping("/api/index/productInfo")
public class IndexProductDetailApiController {
    @Autowired
    private VideoMapper videoMapperDao;//产品路演视频
    @Autowired
    private ProductPageMapper productPageDao;//产品详情
    @Autowired
    private ProductBeiAnMapper productBeiAnDao;//产品备案信息
    @Autowired
    private ProductTagMapper productTagDao;//产品标签
    @Autowired
    private ProductPingLunMapper productPingLunMapper; //产品评论
    @Autowired
    private ProductDetailMapper productDetailDao; //产品详情
    @Autowired
    private ProdAcceDtlMapper prodAcceDtlMapper; //产品附件
    @Autowired
    private ProdAnswAcceDtlMapper prodAnswAcceDtlMapper; //产品评论附件
    @Autowired
    private ValidTokenService validToken; //验证token是否合法
    @Autowired
    private UserOperLogMapper userOperLogMapper;//产品日志
    @Autowired
    private ProdActiInfoMapper prodActiInfoMapper;//产品日志
    @GetMapping("/get")
    @ApiOperation(value = "产品页面",notes = "产品页面",position = 1,response = Object.class)
    public Object getForIndex(String projId,String token){
        ResultModel resultModel=new ResultModel();
        Map<String,Object> resultMap=new HashMap<>();
        Map<String,Object> queryMap=new HashMap<>();
        queryMap.put("projId",projId);
        //2.查询产品信息
        ProductPageBo productPageBo= (ProductPageBo) productPageDao.get(queryMap);
        //保存产品信息
        resultMap.put("product",productPageBo);
        //3.查询产品备案信息
        ProductBeiAnBo productBeiAnBo= (ProductBeiAnBo) productBeiAnDao.get(queryMap);
        String productBeiAnUrl="";
        if(!StringUtil.isNullOrEmpty(productBeiAnBo)){
            productBeiAnUrl=productBeiAnBo.getBakInfoUrl();
        }
        resultMap.put("productBeiAnUrl",productBeiAnUrl);
        resultModel.setCode(ResultStatus.SUCCESS.getCode());
        resultModel.setMessage(ResultStatus.SUCCESS.getMessage());
        resultModel.setData(resultMap);
        return resultModel;
    }


}
